//
//  ViewController.m
//  AddressBookCoreData
//
//  Created by dllo on 15/11/20.
//  Copyright © 2015年 Dior_3g. All rights reserved.
//

#import "ViewController.h"
#import "JHCAddressBookTableViewCell.h"
#import "JHCAddDetailViewController.h"

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain)UITableView *tableView;
@property(nonatomic, retain)NSMutableArray *tableArray;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addressAction:)];
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    
    [self.view addSubview:_tableView];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [_tableView registerClass:[JHCAddressBookTableViewCell class] forCellReuseIdentifier:@"address"];
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    JHCAddressBookTableViewCell *addCell = [tableView dequeueReusableCellWithIdentifier:@"address" forIndexPath:indexPath];
    
    
    addCell.textLabel.text = @"1";
 
    return addCell;
}


- (void)addressAction : (UIBarButtonItem *)button {
    
    JHCAddDetailViewController *addVC = [[JHCAddDetailViewController alloc] init];
    [self.navigationController pushViewController:addVC animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
